package algorithm

// 全部牌值，
// 高四位表示色值(0:万，1：条,2:饼,4:风，5:字)，
// 低四位表示1-9的牌值
var CARDS = []byte{
	0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
	0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
	0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
	0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
	0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
	0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
	0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
	0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
	0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
	0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
	0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
	0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,

	0x41, 0x42, 0x43, 0x44,
	0x41, 0x42, 0x43, 0x44,
	0x41, 0x42, 0x43, 0x44,
	0x41, 0x42, 0x43, 0x44,

	0x51, 0x52, 0x53,
	0x51, 0x52, 0x53,
	0x51, 0x52, 0x53,
	0x51, 0x52, 0x53,
}

// 验证给定的牌是否是有效的麻将牌值
func Legal(card byte) bool {
	if card>>4 > 5 && card>>4 == 3{
		return false
	}
	if card&0xF > 9 || card&0xF <1 {
		return false
	}

	if (card>>4 == 4) && (card&0xF > 4) {
		return false
	}
	if (card>>4 == 5) && (card&0xF > 3 ) {
		return false
	}
	return true
}
